<!-- 班级管理 -->
<div class="wrapper">
	<!-- second-nav -->
	<!-- <div ng-include="'main/manage/nav.html'"></div> -->
	<!-- wrapper-content -->
	<section class="wrapper-content">
		<div class="container-fluid">
			<h2 class="content-title"><span class="margin-right-10">班级管理</span><small>班级列表</small></h2>
		</div>
		<!-- btn-row -->
		<div class="btn-row clearfix">
			<div class="col-md-3">
				<select id="status" class="form-control" ng-model="curYear" ng-change="selectYear()" ng-options="item.name for item in yearList"></select>
			</div>
			<div class="col-md-9">
				<button class="btn btn-primary" ng-click="openAdd()">添加</button>
				<button class="btn btn-primary">批量开班</button>
			</div>
		</div>
		<!-- table-row -->
		<div class="row">
			<div class="container-fluid">
				<div class="col-md-12">
					<table class="table table-bordered" ng-table="classList">
						<tr ng-repeat="item in $data">
							<td title="'序号'" sortable="'sortNum'">{{item.sortNum}}</td>
							<td title="'名称'" sortable="'name'">{{item.name}}</td>
							<td title="'班级类型'" sortable="'classTypeName'">{{item.classTypeName}}</td>
							<td title="'主教老师'">{{item.user.name}}</td>
							<td title="'描述'">{{item.description}}</td>
							<td title="'操作'">
								<div class="btn-group">
	                                <button href="javascript:void(0);" ng-click="openEdit(item);" class="btn btn-sm btn-success" title="编辑"><i class="fa fa-pencil"></i></button>
	                                <button href="javascript:void(0);" ng-click="openDel(item);" class="btn btn-sm btn-warning" title="删除"><i class="fa fa-times"></i></button>
	                            </div>
							</td>
						</tr>
					</table>
					<div class="row">
						<div class="col-md-6">
							<div class="pull-left btn btn-default">总数：<span class="badge">{{ totalRow }}</span></div>	
						</div>
						<div class="col-md-6">
							<!-- 分页 -->
							<nav>
								<ul class="pagination ng-table-pagination fr">
									<li>
										<a ng-click="previous()"><span>上一页</span></a>
									</li>
									<li ng-repeat="page in pageList" ng-class="{active: isActivePage(page)}" >
										<a ng-click="getClassesList(page)">{{ page }}</a>
									</li>
									<li>
										<a ng-click="next()"><span>下一页</span></a>
									</li>
								</ul>
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!-- 新增班级 addClassModel -->
		<div class="modal" id="addClassModel" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-lg" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">新建班级</h3>
					</div>
					<div class="modal-body">
						<div class="form-horizontal">
							<!-- 名称 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="inputName">名称</label>
								</div>
								<div class="col-md-6">
									<input type="text" id="inputName" class="form-control" ng-model="newClassItem.name" ng-change="watchName('new')">
								</div>
								<div class="col-md-3 text-danger" ng-bind="newClassItem.warn.name"></div>
							</div>
							<!-- 班级类型 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="classTypeId">班级类型</label>
								</div>
								<div class="col-md-6">
									<select id="classTypeId" class="form-control" ng-model="newClassItem.select.classTypeId" ng-options="item.name for item in newClassItem.classTypeList" ng-change="watchClassTypeId('new')">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
								<div class="col-md-3 text-danger" ng-bind="newClassItem.warn.classTypeId"></div>
							</div>
							<!-- 班徽 -->
							<div class="form-group">
								<div class="clearfix">
									<div class="control-label col-md-3">
									    <span ng-show="false" class="text-danger">*</span>
									    <label for="logo">班徽</label>
									</div>
									<div class="col-md-6">
										<button class="btn btn-primary margin-bottom-10" ngf-select="uploadLogo('new', $files)" ngf-pattern="'image/*'" ngf-multiple="false"><i class="fa fa-upload" aria-hidden="true"></i>选择文件</button>
									</div>
								</div>
								<div class="clearfix">
									<div class="col-md-3"></div>
									<div class="col-md-6">
										<div class="com-file-upload">
											<ul>
												<li ng-repeat="file in newClassItem.logo">
													<img ngf-src="file">
													<span class="delete" ng-click="delete('new')"><i class="fa fa-remove"></i></span>
													<a href="javascript:void(0);" ng-click="download(file)" class="com-file-detail">{{file.name}}（{{file.size | parseBit}}）</a>
												</li>
											</ul>
										</div>	
									</div>
								</div>
							</div>
							<!-- 最大学生数 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="maxQuotas">最大学生数</label>
								</div>
								<div class="col-md-6">
									<input type="number" id="maxQuotas" ng-model="newClassItem.maxQuotas" ng-change="watchMaxQuotas('new')" class="form-control" max="999" min="0">
								</div>
								<div class="col-md-3 text-danger" ng-bind="newClassItem.warn.maxQuotas"></div>
							</div>
							<!-- 考勤日历 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="calendarId">考勤日历</label>
								</div>
								<div class="col-md-6">
									<ui-select id="calendarId" ng-model="newClassItem.select.calendarId">
										<ui-select-match placeholder="选择...">
											<span>{{$select.selected.name}}</span>
										</ui-select-match>
										<ui-select-choices repeat="item in newClassItem.calendarList | filter: $select.search">
											<div ng-bind="item.name"></div>
										</ui-select-choices>
									</ui-select>
								</div>
							</div>
							<!-- 主教老师 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="userId">主教老师</label>
								</div>
								<div class="col-md-6">
									<select id="userId" class="form-control" ng-model="newClassItem.select.userId" ng-options="item.name for item in newClassItem.userList">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
							</div>
							<!-- 序号 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="sortNum">序号</label>
								</div>
								<div class="col-md-6">
									<input type="number" id="sortNum" ng-model="newClassItem.sortNum" class="form-control">
								</div>
							</div>
							<!-- 描述 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="description">描述</label>
								</div>
								<div class="col-md-6">
									<textarea name="" id="description" cols="30" rows="10" class="form-control" ng-model="newClassItem.description"></textarea>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="addClasses()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>
	
		<!-- 删除 delClassModel -->
		<div class="modal" id="delClassModel" tabindex="-1" role="dialog">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">删除班级</h3>
					</div>
					<div class="modal-body">
						<p class="text-danger text-center">删除将造成相关数据丢失，请确认是否继续删除。</p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="delClasses()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>
		
		<!-- 修改 editClassModel -->
		<div class="modal" id="editClassModel" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-lg" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">编辑班级</h3>
					</div>
					<div class="modal-body">
						<div class="form-horizontal">
							<!-- 名称 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="inputName_mod">名称</label>
								</div>
								<div class="col-md-6">
									<input type="text" id="inputName_mod" class="form-control" ng-model="modClassItem.classes.name" ng-change="watchName('edit')">
								</div>
								<div class="col-md-3 text-danger" ng-bind="modClassItem.warn.name"></div>
							</div>
							<!-- 班级类型 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="classTypeId_mod">班级类型</label>
								</div>
								<div class="col-md-6">
									<select id="classTypeId_mod" class="form-control" ng-model="modClassItem.select.classTypeId" ng-options="item.name for item in modClassItem.classTypeList" ng-change="watchClassTypeId('edit')">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
								<div class="col-md-3 text-danger" ng-bind="modClassItem.warn.classTypeId"></div>
							</div>
							<!-- 班徽 -->
							<div class="form-group">
								<div class="clearfix">
									<div class="control-label col-md-3">
									    <span ng-show="false" class="text-danger">*</span>
									    <label for="logo_mod">班徽</label>
									</div>
									<div class="col-md-6">
										<button class="btn btn-primary margin-bottom-10" ngf-select="uploadLogo('edit', $files)" ngf-pattern="'image/*'" ngf-multiple="false"><i class="fa fa-upload" aria-hidden="true"></i>选择文件</button>
									</div>
								</div>
								<div class="clearfix">
									<div class="col-md-3"></div>
									<div class="col-md-6">
										<div class="com-file-upload">
											<ul>
												<li ng-repeat="file in modClassItem.classes.logo">
													<img ng-if="isString(file)" ng-src="{{file}}">
													<img ng-if="!isString(file)" ngf-src="file">
													<span class="delete" ng-click="delete('edit')"><i class="fa fa-remove"></i></span>
													<a ng-if="!isString(file)" href="javascript:void(0);" ng-click="download(file)" class="com-file-detail">{{file.name}}（{{file.size | parseBit}}）</a>
												</li>
											</ul>
										</div>	
									</div>
								</div>
							</div>
							<!-- 最大学生数 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label for="maxQuotas_mod">最大学生数</label>
								</div>
								<div class="col-md-6">
									<input type="number" id="maxQuotas_mod" ng-model="modClassItem.classes.maxQuotas" ng-change="watchMaxQuotas('edit')" class="form-control" max="999" min="0">
								</div>
								<div class="col-md-3 text-danger" ng-bind="modClassItem.warn.maxQuotas"></div>
							</div>
							<!-- 考勤日历 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="calendarId_mod">考勤日历</label>
								</div>
								<div class="col-md-6">
									<ui-select id="calendarId_mod" ng-model="modClassItem.select.calendarId">
										<ui-select-match placeholder="选择...">
											<span>{{$select.selected.name}}</span>
										</ui-select-match>
										<ui-select-choices repeat="item in modClassItem.calendarList | filter: $select.search">
											<div ng-bind="item.name"></div>
										</ui-select-choices>
									</ui-select>
								</div>
							</div>
							<!-- 主教老师 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="userId_mod">主教老师</label>
								</div>
								<div class="col-md-6">
									<select id="userId_mod" class="form-control" ng-model="modClassItem.select.userId" ng-options="item.name for item in modClassItem.userList">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
							</div>
							<!-- 其他教师 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="userId_mod">其他教师</label>
								</div>
								<div class="col-md-6">
									<button class="btn btn-primary" ng-click="addOtherUserForm();">添加</button>
								</div>
							</div>
							<div class="form-group">
								<div class="col-md-3"></div>
								<div class="col-md-6">
									<table class="table table-bordered" ng-table="modClassItem.otherClassesUser">
										<tr ng-repeat="item in $data">
											<td title="'老师'" sortable="'userId'">{{item.userId}}</td>
											<td title="'关系名称'" sortable="'relationName'">{{item.relationName}}</td>
											<td title="'操作'">
												<div class="btn-group">
					                                <button href="javascript:void(0);" ng-click="openEdit(item);" class="btn btn-sm btn-success" title="编辑"><i class="fa fa-pencil"></i></button>
					                                <button href="javascript:void(0);" ng-click="openDel(item);" class="btn btn-sm btn-warning" title="删除"><i class="fa fa-times"></i></button>
					                            </div>
											</td>
										</tr>
									</table>
								</div>
							</div>
							<!-- 序号 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="sortNum_mod">序号</label>
								</div>
								<div class="col-md-6">
									<input type="number" id="sortNum_mod" ng-model="modClassItem.classes.sortNum" class="form-control">
								</div>
							</div>
							<!-- 描述 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label for="description_mod">描述</label>
								</div>
								<div class="col-md-6">
									<textarea name="" id="description_mod" cols="30" rows="10" class="form-control" ng-model="modClassItem.classes.description"></textarea>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="editClasses()">确认</button>
						<button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
					</div>
				</div>
			</div>
		</div>
		<!-- otherTeaModel -->
		<div class="modal" id="otherTeaModel" data-focus-on="input:first" tabindex="-1" role="dialog">
			<div class="modal-dialog modal-lg" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> -->
						<button type="button" class="close" aria-label="Close" ng-click=hide('#otherTeaModel')><span aria-hidden="true">&times;</span></button>
        				<h3 class="modal-title">添加</h3>
					</div>
					<div class="modal-body">
						<div class="form-horizontal">
							<!-- 老师 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="true" class="text-danger">*</span>
								    <label>老师</label>
								</div>
								<div class="col-md-6">
									<select class="form-control" ng-model="otherTea.name" ng-options="item.name for item in otherTea.userList">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
							</div>
							<!-- 关系 -->
							<div class="form-group">
								<div class="control-label col-md-3">
								    <span ng-show="false" class="text-danger">*</span>
								    <label>关系</label>
								</div>
								<div class="col-md-6">
									<select class="form-control" ng-model="otherTea.relationName" ng-options="item.name for item in modClassItem.userList">
										<option value="">-- 请选择 --</option>
									</select>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary" ng-click="addOtherUser()">确认</button>
						<button type="button" class="btn btn-warning" ng-click=hide('#otherTeaModel')>取消</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 提示 infoModel -->
		<info-modal msg="msg" visible="visible"></info-modal>
	</section>
</div>
